package realQuestion.yongyou;

public class Main1 {

    public int maxValue (int[][] grid) {
        if (grid.length==0){
            return 0;
        }
        int x = grid.length;
        int y = grid[0].length;
        int[][]dp=new int[x][y];

        dp[0][0]=grid[0][0];
        for (int i = 1; i <y ; i++) {
            dp[0][i]=grid[0][i]+dp[0][i-1];
        }
        for (int i = 1; i <x ; i++) {
            dp[i][0]=grid[i][0]+dp[i-1][0];
        }
        for (int i = 1; i <x ; i++) {
            for (int j = 1; j <y ; j++) {
                dp[i][j]=grid[i][j]+Math.max(dp[i-1][j],dp[i][j-1]);
            }
        }
        return  dp[x-1][y-1];
    }

    public static void main(String[] args) {
        int[][]  test={
            {1,2,3},{3,4,0}
        };
        System.out.println(test.length);
        System.out.println(test[0].length);
    }


}
